from django.db import models
from django.contrib.auth.models import User
from datetime import datetime    
from l2ldjango.apps.jobsapp.extra import *
from django.template.defaultfilters import slugify
from l2ldjango.apps.usermanagement.models import PracticeArea
#from l2l.apps.blog.models import * 

STATUS_CHOICES = ((1,'ACTIVE'),
                      (2, 'INACTIVE'),
                      )
# Create your models here.
class Jobs(models.Model):
    title=models.CharField(max_length=225,null=False,blank=False,verbose_name="Job Title")
    job_created=models.DateField(auto_now_add=True)
    job_position=models.CharField(max_length=255,null=False,blank=False,verbose_name='Job Position')
    posted_by=models.ForeignKey(User,null=True,blank=True)
    description=models.TextField(null=False,blank=False,verbose_name="Job Description")
    dead_line=models.DateField(null=True,blank=True,verbose_name="Dead Line")
    academic_requirements=models.TextField(null=True,blank=True,verbose_name="Academic Qualifications")
    other_requirements=models.TextField(null=True,blank=True,verbose_name="Other Requirements")
    job_experience=models.TextField(null=True,blank=True,verbose_name="Job Experience")
    vacancies=models.IntegerField(null=False,blank=False,default=1,verbose_name="Number of Vacancies")
    salary=models.CharField(max_length=255,null=True,blank=True,verbose_name="Salary")
    company=models.CharField(null=False,blank=False,max_length=250,verbose_name="Company Name")
    company_website=models.URLField(null=False,blank=False,verbose_name="Company Website")
    location=models.CharField(null=False,blank=False,max_length=255)
    practice_areas=models.ManyToManyField(PracticeArea,null=True,blank=True,related_name="practice_areas")   
    job_status=models.IntegerField(null=False,blank=False,choices=STATUS_CHOICES, default=1,verbose_name="Status")
    def __str__(self):
        return self.title
    
class JobsApplications(models.Model):
    job=models.ForeignKey(Jobs,null=True,blank=True)
    applicant=models.ForeignKey(User,null=True,blank=True)
    applicant_name=models.CharField(null=True,blank=True,max_length=255,verbose_name="Full Name")
    applicant_email=models.CharField(null=True,blank=True,max_length=255,verbose_name="Email")
    applicant_cv=ContentTypeRestrictedFileField(upload_to='cv_files',null=True,blank=True,verbose_name="Resume",max_upload_size=1048576)
    status=models.BooleanField(default=True)
    